# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import datetime

from django.db import models

# Create your models here.


class Course(models.Model):
	name = models.CharField(verbose_name=u'课程名称', max_length=50)
	desc = models.CharField(verbose_name=u'课程描述', max_length=300)
	detail = models.TextField(verbose_name=u'课程详情')
	degree = models.CharField(verbose_name=u'课程难度', choices=(('cj', u'初级'), ('zj', u'中级'), ('gj', u'高级')), max_length=2)
	learn_time = models.IntegerField(verbose_name=u'学习时长（分钟）', default=0)
	students = models.IntegerField(verbose_name=u'学习人数', default=0)
	fav_nums = models.IntegerField(verbose_name=u'收藏人数', default=0)
	image = models.ImageField(verbose_name=u'课程封面', upload_to='static/media/courses/image_Course/%Y/%m', max_length=100)
	click_nums = models.IntegerField(verbose_name=u'点击数', default=0)
	create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.now)

	class Meta:
		verbose_name = u'课程'
		verbose_name_plural = verbose_name

	def __unicode__(self):
		return self.name


class Lesson(models.Model):
	couser = models.ForeignKey('Course', verbose_name=u'课程')
	name = models.CharField(verbose_name=u'章节名称', max_length=100)
	ceate_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.now)

	class Meta:
		verbose_name = u'章节'
		verbose_name_plural = verbose_name

	def __unicode__(self):
		return self.name


class Video(models.Model):
	lesson = models.ForeignKey('Lesson', verbose_name=u'章节')
	name = models.CharField(verbose_name=u'视频名称', max_length=100)
	create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.now)

	class Meta:
		verbose_name = u'视频'
		verbose_name_plural = verbose_name

	def __unicode__(self):
		return self.name


class CourseResource(models.Model):
	course = models.ForeignKey('Course', verbose_name='课程')
	name = models.CharField(verbose_name='资源名称', max_length=100)
	download = models.FileField(verbose_name=u'资源文件', upload_to='static/media/cousers/CourseResource/%Y/%m')
	create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.now)

	class Meta:
		verbose_name = u'课程资源'
		verbose_name_plural = verbose_name

	def __unicode__(self):
		return self.name
